<?php

class db_indoherbal{

        var $host;
        var $user;
        var $pass;
        var $dbnm;
        var $db;
        
        function __construct($host,$user,$pass,$dbnm){
			    $this->host = $host;
                $this->user = $user;
                $this->pass = $pass;
                $this->dbnm = $dbnm;
        }
        
        function _connect(){
                $this->db = mysql_connect($this->host,$this->user,$this->pass);
                mysql_select_db($this->dbnm,$this->db);
        }
        
                function get_data(){
                        
                        $this->_connect();
                        
                        $sql = 'SELECT * FROM datauser ORDER BY id_pengguna DESC';
                        $result = mysql_query($sql);
                        return $result;
                }
                
                function set_data($data){
                
                        $this->_connect();
                
                        $sql = '
                                INSERT 
                                INTO
                                datauser
                                (
                                        nama,
                                        username,
                                        email,
                                        password,
                                        alamat,
                                        nohp,
                                        foto
										                                )
                                VALUES
                                (
                                        "'.$data['nama'].'",
                                        "'.$data['username'].'",
                                        "'.$data['email'].'",
                                        md5("'.$data['password'].'"),
                                        "'.$data['alamat'].'",
                                        "'.$data['nohp'].'",
                                        "'.$data['foto'].'"
										                          )
                        ';
		
                        
                        $result = mysql_query($sql);
						if($result){	
							header('location:login.php?message=success');
						}
						else {
							header('location:login.php?message=warning');
						}
                }
                
                /*
                function del_data($id){
                    $sql =  'DELETE FROM diary where id_diary="'.$id.'" LIMIT 1'; 
                        $result = mysql_query($sql); 
                        return $result;
                }
                */
}